<template>
	<uni-search-bar @confirm="toSearch" placeholder="请输入要搜索的公共交通路线" v-model="searchkey" />
	<swiper style="height: 200px;" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
		<swiper-item v-for="(item,index) in lunboList" :key="index">
			<view class="swiper-item">
				<image style="width: 100%;" :src="item.url" mode=""></image>
			</view>
		</swiper-item>
	</swiper>
</template>

<script setup>
	import {
		onLoad
	} from "@dcloudio/uni-app"
	import {
		ref
	} from "vue"
	import {
		CONFIG
	} from "../../utils/config"
	const searchkey = ref("")

	function toSearch() {
		if (searchkey.value == "") {
			uni,
			uni.showToast({
				title: '请输入要搜索的公共交通路线',
				icon: "none"
			});
		}
		else {
			window.location.href =
				`https://uri.amap.com/line?name=${searchkey.value}&city=029&callnative=1`
		}
	}
	onLoad(() => {
		getLuinbo()
	})
	const lunboList = ref([])
	async function getLuinbo() {
		let res = await uni.$get(CONFIG.leanCloud_url + "/1.1/classes/images")
		if (res.statusCode == 200) {
			lunboList.value = res.data.results
		}
		console.log(lunboList.value)
	}
</script>

<style lang="scss" scoped>

</style>